<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <my-cpn title='666'></my-cpn>

        <div :style="{ fontSize: postFontSize + 'em' }">
            <text-up v-for="item in listdata" :title="item" @enlargetext="enlarge"></text-up>
        </div>
    </div>

    <script>
        Vue.component('my-cpn', {
            data: function () {
                return {
                    count: 0
                }
            },
            props: ['title'],
            template: '<h1>{{title}}</h1>'
        })

        Vue.component('text-up', {
            props: ['title'],
            template: `
            <div><h1>{{title}}</h1><button @click="$emit('enlargetext')">字体变大</button></div>`
        })

        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {
                listdata: [
                    '父子组件传值', '渡口', '凤凰花开的路口'
                ],
                postFontSize: 1

            },
            methods: {
                enlarge() {
                    this.postFontSize = this.postFontSize + 0.1
                }
            }
        });
    </script>
</body>

</html>